
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php if (!session_id()) session_start(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>电子商务售后单</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="demo.css" rel="stylesheet" type="text/css" />
    <script src="scripts/boot.js" type="text/javascript"></script>
	<style>

	</style>
    
</head>
<body >

 <fieldset id="fd1" style="border: 1px solid gray;height: 100px">
        <legend><span>搜索</span></legend>
        <div  id='fm1'>
        <div class="fieldset-body">
          客户代码:  <div class="mini-autocomplete" style="width:250px;"  popupWidth="400" textField="text" valueField="id"  id='U_CardCode' name='U_CardCode'
        url="" value="" text=""  onvaluechanged="onValueChanged"  enabled='false'>     
        <div property="columns">
            <div header="客户代码" field="id" width="30"></div>
            <div header="客户名称" field="text"></div>
        </div>
    </div>
    
           客户名称:  <div class="mini-autocomplete" style="width:250px;"  popupWidth="400" textField="text" valueField="id" 
        url="" value="" text=""  onvaluechanged="onValueChanged" id='U_CardName' name = 'U_CardName' enabled='false'enabled='false'>      
        <div property="columns">
            <div header="客户代码" field="id" width="30"></div>
            <div header="客户名称" field="text"></div>
        </div>`
    </div>
          买家姓名： <input id="U_Cstname"  name="U_Cstname" class="mini-textbox" enabled='false' />
       手机号码： <input  id="U_Phone"  name="U_Phone" class="mini-textbox"  value="" enabled='false' />  <br/><br/>
                 订单号： <input  id="orderId"  name="orderId" class="mini-textbox"  value="" /> 
          <a class="mini-button" onclick="search" enabled="" >&nbsp;&nbsp;查询&nbsp;&nbsp;</a>   
        </div>
          </div>
    </fieldset>
  
   
    <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
    buttons="#tabsButtons"
>
   <div title="售后明细" >
   
    <div id="datagrid1" class="mini-datagrid" style="height:300px;width: 100%;" 
        url="" idField="id"
        allowResize="true" 
        allowCellEdit="true" allowCellSelect="true" multiSelect="true"
        allowCellValid="true" oncellvalidation="" showPager='false'
    >
        <div property="columns">
            <div field="U_BsEntry" vtype=""   headerAlign="center"  >售前单序号
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>    
            
            
             <div field="U_ItemCode" vtype=""   headerAlign="center"  >投诉物料代码
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>    
            
             <div field="U_ItemName" vtype=""   headerAlign="center"  >投诉物料名称
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>           
            
              <div field="U_Dealer"   headerAlign="center"  >售后客服代码
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
            
             <div field="U_DealerName"  headerAlign="center"  >售后客服名称
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
            
            
             <div field="U_AlloStatus" vtype=""   headerAlign="center"  renderer="onGenderU_AlloStatus" >分配状态
              <input property="editor" class="mini-combobox" style="width:100%;" data="U_AlloStatus"/>   
            </div>  
            
               <div field="U_Priority"  width="100" renderer="onGenderU_Priority" align="center" headerAlign="center">优先级
                <input property="editor" class="mini-combobox" style="width:100%;" data="U_Priority"/>                
            </div>
            
            
               <div field="U_AccuName"  width="100"  align="center" headerAlign="center">投诉次数描述
                <input property="editor" class="mini-combobox" style="width:100%;" data="Genders"/>                
            </div>
            
            
              <div field="U_AccuQCLs"  width="100" renderer="onGenderU_AccuQCLs" align="center" headerAlign="center">投诉问题大类
                <input property="editor" class="mini-combobox" style="width:100%;" data="U_AccuQCLs"/>                
            </div>
            
            
            
            <div field="U_AccuDate"     >投诉日期
                <input property="editor" class="mini-datepicker" style="width:100%;" valueType='string'   format="yyyy-MM-dd" />                
            </div>
              <div field="U_AccuTime"     >投诉时间
                <input property="editor" class="mini-datepicker" style="width:100%;" valueType='string'  format=" Hmm"  timeFormat="H:mm" showTime="true" />                
            </div>
            
              
            <div field="U_AccuTel" vtype=""   headerAlign="center"  >投诉人电话号码
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
              
            <div field="U_AccuPers" vtype=""   headerAlign="center"  >投诉人
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
            
            <div field="U_AccuDetl" vtype=""   headerAlign="center"  >售后问题描述
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
              
               <div field="U_AccuQDtl" vtype=""   headerAlign="center"  >售前问题描述
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
              
              
                <div field="U_CustAdr" vtype=""   headerAlign="center"  >客户地址
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
              <div field="U_QSummary" vtype=""   headerAlign="center"  >问题总结
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
               <div field="U_ProSts"  width="100" renderer="onGenderRenderer" align="center" headerAlign="center">处理状态
                <input property="editor" class="mini-combobox" style="width:100%;" data="Genders"/>                
            </div>
            
              
             
            <div field="U_ProEndDate"     >处理结束日期
                <input property="editor" class="mini-datepicker" style="width:100%;" valueType='string'   format="yyyy-MM-dd" />                
            </div>
              <div field="U_ProEndTime"     >处理结束时间
                <input property="editor" class="mini-datepicker" style="width:100%;" valueType='string'  format=" Hmm"  timeFormat="H:mm" showTime="true" />                
            </div>
            
          
        </div>
    </div>
    
    
    </div>
    <!-- <div title="Tab2" iconCls="" >
        2
    </div> -->
</div>

  <div id='editForm1'>
  <!-- 
    售前问题描述：<textarea class="mini-textarea" emptyText="" style="width: 30%;margin-top: 5px" id='U_AccuQDtl' name='U_AccuQDtl'></textarea> <br />
    售后问题描述：<textarea class="mini-textarea" emptyText="" style="width: 30%;margin-top: 5px"id='U_AccuDetl' name='U_AccuDetl'></textarea> <br />
 -->
    <br />
     
    <a class="mini-button" onclick="save" enabled="" id='update-bt' style="">&nbsp;&nbsp;添加&nbsp;&nbsp;</a>
    <a class="mini-button" onclick="clear" enabled="" id='colse-tb'>&nbsp;&nbsp;取消&nbsp;&nbsp;</a>
  </div>
</body>
<script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        var Genders = [{'id':'1','text':'未完成'},{'id':'2','text':'处理中'},{'id':'3','text':'已完成'}];
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {
                var g = Genders[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }
        var U_AccuQCLs = [{'id':'1','text':'1--质量问题'},{'id':'2','text':'2--快递运输问题'},{'id':'3','text':'3--发票问题'},{'id':'4','text':'4--商品信息问题'},{'id':'5','text':'5--发货问题'},{'id':'6','text':'5--其他'},{'id':'0','text':'0-- -'}];
        
        function onGenderU_AccuQCLs(e) {
            for (var i = 0, l = U_AccuQCLs.length; i < l; i++) {
                var g = U_AccuQCLs[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }


     var U_Priority = [{'id':'1','text':'1--高'},{'id':'2','text':'2--中'},{'id':'3','text':'3--低'}];
        
        function onGenderU_Priority(e) {
            for (var i = 0, l = U_Priority.length; i < l; i++) {
                var g = U_Priority[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }

  var U_AlloStatus = [{'id':'Y','text':'已分配'},{'id':'N','text':'未分配'}];
        
        function onGenderU_AlloStatus(e) {
            for (var i = 0, l = U_AlloStatus.length; i < l; i++) {
                var g = U_AlloStatus[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }

        

        
        ///////////////////////////////////////////////////////
		var db = new mini.DataBinding();
        db.bindForm("editForm1", grid);
        function removeRow() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                grid.removeRows(rows, true);
            }
        }

      

      
        function save() {
            var data = grid.getChanges()[0];
             var json = mini.encode(data);
              if(data.U_AccuQCLs==null){
				mini.alert('投诉问题大类不能为空!');
				return ;
              } 
           
            var form = new mini.Form("#fm1");            
            var fmdata = form.getData();      //获取表单多个控件的数据
            var U_Suggest = mini.get('U_Suggest').getValue();
            fmdata.U_Suggest=U_Suggest;
            var fmjson = mini.encode(fmdata); //序列化成JSON
            mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '保存中...'
            });

           
            $.ajax({
                url: "/sale/saveCustAjax",
                data: { data: json,fmdata:fmjson},
                type: "post",
                success: function (text) {
                   if(text>0){
                	    mini.unmask(document.body);
						mini.alert('添加成功');
						clear();
                   }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

        function search(){
      	
			var khcode = mini.get('U_CardCode').getValue();
			var orderId = mini.get('orderId').getValue();
			if(orderId==''){
			   mini.alert('必须输入订单号');
			   return ;
		    }

			   mini.mask({
		            el: document.body,
		            cls: 'mini-mask-loading',
		            html: '数据加载中....'
		        }); 
      	  $.ajax({
              url: "/sale/getCustdataAjax",
              data: { orderId: orderId },
              type: "post",
              dataType:'json',
              success: function (data) {
            	  mini.get('U_CardName').setValue(data['fmData'].U_CardName);
            	  mini.get('U_CardName').setText(data['fmData'].U_CardName);
            	  mini.get('U_CardCode').setValue(data['fmData'].U_CardCode);
            	  mini.get('U_CardCode').setText(data['fmData'].U_CardCode);
            	  mini.get('U_Cstname').setValue(data['fmData'].U_Cstname);
            	  mini.get('U_Phone').setValue(data['fmData'].U_Phone);
            	 // grid.setData(data.preData)
            	  //var no = grid.getData().length+1;
            	  if(!data.preData){
					var no=1;
                  }else
            	  var no = data.preData.length+1;
            	  var newRow = {rowStatus:'add',U_AccuName:"第"+no+"次投诉!",U_ItemCode:data['fmData'].U_ItemCode,U_ItemName:data['fmData'].U_ItemName };
            	  newRow.U_AlloStatus='Y';
            	  newRow.U_AccuTel=data['fmData'].U_Phone;
            	  newRow.U_AccuPers=data['fmData'].U_Cstname;
            	
            	  newRow.U_CustAdr=data['fmData'].U_Address;
            	  newRow.U_Dealer='<?php echo $_SESSION['emp_no']?>';
            	  newRow.U_DealerName='<?php echo $_SESSION['user_name']?>';
            	  newRow.U_AlloStatus='Y';
                	
                  grid.addRow(newRow, 0);

                  
                  grid.validateRow(newRow);   //加入新行，马上验证新行
                  mini.unmask(document.body);
              },
              error: function (jqXHR, textStatus, errorThrown) {
                  alert(jqXHR.responseText);
              }
          });

            }
        function clear(){
         	 grid.setData(null);
           }

    </script>

</html>